package interfaces.spawnMenu.costumize.hunters;

import logic.ships.hunter.Hunter;
import logic.weapons.WeaponType;
import main.InitGame;
import main.listeners.listenerClasses.LanguageListener;

import org.fenggui.binding.render.ImageFont;

import fileHandling.language.Lang;
import fileHandling.language.LanguageLoader;
import fileHandling.language.interfaces.SpawnMenuText;

import interfaces.superWidgets.KeyValueContent;

public class HunterDetailsContent extends KeyValueContent {
	
	private Hunter hunter;
	
	public HunterDetailsContent(int width, int height, ImageFont font) {
		super(width, height, font, true);
		
		InitGame.get().addLanguageListener(new LanguageListener() {
			@Override
			public void languageChanged() {
				if(hunter != null) init(hunter);
			}
		});
	}
	
	public void init(Hunter hunter) {
		clear();
		
		this.hunter = hunter;
		
		String left = LanguageLoader.get(SpawnMenuText.Selected_Hunter);
		String right = hunter.getHunterName();
		addLine(left, right);
		
		addWeaponSlotLine(SpawnMenuText.Energy_Weapon_Slots, WeaponType.Energy);
		addWeaponSlotLine(SpawnMenuText.Heatseaker_Slots, WeaponType.HeatSeeker);
		addWeaponSlotLine(SpawnMenuText.Missile_Slots, WeaponType.Missile);
		
		layout();
	}
	
	private void addWeaponSlotLine(Lang leftLang, WeaponType type) {
		String left = LanguageLoader.get(leftLang);
		String right = "" + hunter.getWeapontSlotsNumber(type);
		addLine(left, right);
	}
	
	public boolean isInit() { return hunter != null; }
}